package com.yu.judge.strategy.strategymanage;

import com.yu.judge.strategy.DefaultJudgeStrategy;
import com.yu.judge.strategy.JudgeContext;
import com.yu.judge.strategy.JudgeStrategy;
import com.yu.judge.model.JudgeInfo;
import com.yu.model.entity.QuestionSubmit;
import org.springframework.stereotype.Service;

/**
 * 此类就是为了解决之前提出的可能有不同的代码语言
 * 所以创建此管理类 决定什么语言时此管理类来决定调用什么判题
 * 另此也可管理后续如果有什么特殊的判题方法时，用此来决定
 * 加@Service 目的为了更加方便的引用
 */

@Service
public class StrategyManage {

    public JudgeInfo doJudge(JudgeContext judgeContext) {

        QuestionSubmit questionSubmit = judgeContext.getQuestionSubmit();
        JudgeStrategy judgeStrategy=new DefaultJudgeStrategy();
        if(questionSubmit.getLanguage().equals("java")){

            judgeStrategy=new DefaultJudgeStrategy();
        }

        return judgeStrategy.doJudge(judgeContext);
    }
}
